import { BizConfigUtils } from '@/common/biz-config-utils'
import { DeviceModel } from './device-model'
import axios from 'axios'

export class DeviceApi {
  private static serverAddress = `${BizConfigUtils.getGlobalConfig().serveAddress}/device`
  public static save (data: DeviceModel):Promise<any> {
    console.log('保存用户', data)
    return axios.post(this.serverAddress, data)
  }

  public static query (pageIndex:number, pageSize:number, name = null):Promise<any> {
    const url = this.serverAddress + '/page?pageIndex=' + pageIndex + '&pageSize=' + pageSize + (!name ? '' : '&name=' + name)
    return axios.get(url)
  }

  public static get (id:string):Promise<any> {
    return axios.get(this.serverAddress + '/' + id)
  }

  public static delete (id:string):Promise<any> {
    return axios.delete(this.serverAddress + '/' + id)
  }

  public static getDeviceListByTeamId ():Promise<any> {
    const loginUser = BizConfigUtils.getLoginUser()
    return axios.get(this.serverAddress + '/teamid/' + loginUser.teamId)
  }
}
